﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SimpleData.ObjectModel;

namespace SimpleData.Infrastruture.Collections
{
	/// <summary>
	/// Tabela hash para leitura rápida
	/// </summary>
	public sealed class MyHashTable
	{
		private static readonly char[] validHashChars = DocumentTokenHelper.TokenChars();

		private int count;
		private object[] buckets;
		private string[] keys;
		private IEqualityComparer<string> comparer;
		


		public MyHashTable()
			: this( 16 )
		{ }

		public MyHashTable( int initialCapacity )
		{
			this.ResizeBuckets( initialCapacity );
		}


		public object Get( string key )
		{
			return null;
		}

		/// <summary>
		/// Adiciona o valor <paramref name="value"/> somente se a chave <paramref name="key"/> não existe
		/// na coleção.
		/// </summary>
		/// <param name="key"></param>
		/// <param name="value"></param>
		/// <returns>Retorna true se o valor foi adicionado na coleção, indicando que a chave não existia</returns>
		public bool AddIfNotExists(string key, object value)
		{
			return false;
		}

		public void Set( string key, object value )
		{
			string upperKey = key.ToUpper();

			int keyIndex = 0;

			while ( keyIndex < key.Length )
			{
				int code = Array.IndexOf( MyHashTable.validHashChars, upperKey[ keyIndex++ ] );


			}
		}

		private void ResizeBuckets( int newSize )
		{

		}
	}
}
